package com.example.aop.aop;

import com.sun.javafx.util.Logging;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component  //3、定义为bean受spring管控
@Aspect //3、定义切面
public class userAdvice {


   /* //前置通知
    //2、定义切点
    @Pointcut(value = "execution(void com.example.aop.service.userService.insertUser())")
    private void pt(){}
    //1、定义方法，共性功能
    @Before(value = "pt()")
    private void method(){
        System.out.println(System.currentTimeMillis());
    }*/

    //环型通知,以后常用
    @Pointcut(value = "execution(void com.example.aop.service.userService.insertUser())")
    private void pt(){}

    @Around("pt()")
    private void method(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println(System.currentTimeMillis());//切点之前的操作
        //调用原始方法
        proceedingJoinPoint.proceed();//切点后的操作
        System.out.println(System.currentTimeMillis());
    }

}
